package com.itheima.mapper;

import com.itheima.dto.SetmealDto;
import com.itheima.entity.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealMapper {
    @Select("select count(*) from setmeal where category_id=#{id}")
    long findSetmealCountById(long id);

    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void saveWithSetmeal(SetmealDto setmealDto);

    List<Setmeal> findByName(String name);

    void delete(@Param("ids") List<Long> ids);

    long findstsatsCount(@Param("ids") List<Long> ids);

    @Select("select *from setmeal where category_id=#{categoryId} and status=#{status}")
    List<Setmeal> list(@Param("categoryId") long categoryId, @Param("status") Integer status);

    void status(@Param("status") Integer status, @Param("ids") List<Long> ids);

    @Select("select * from setmeal where id=#{id}")
    Setmeal findById(long id);

    void updateById(SetmealDto setmealDto);
    //强制修改未停售
    void statusStop(@Param("ids") List<Long> ids);
}
